from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from goods.models import SPUSpecification,SPU
from meiduo_admin.serializers.specs_ser import SpecSerializer, SPUSeriallizer
from meiduo_admin.utils import PageNum


class SpecView(ModelViewSet):
    """
        商品规格的管理
    """
    queryset = SPUSpecification.objects.all()
    serializer_class = SpecSerializer
    permission_classes = [IsAdminUser]
    pagination_class=PageNum

    # 获取商品spu信息
    def simple(self,request):
        spus=SPU.objects.all()
        ser=SPUSeriallizer(spus,many=True)
        return Response(ser.data)